<%@page import="java.util.Locale"%>
<%@page import="java.util.ResourceBundle"%>
<%@page import="java.util.Date"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="server.Utils"%>
<%@page import="model.Articles"%>
<%@page import="java.util.ArrayList"%>
<%@page import="javax.cache.CacheException"%>
<%@page import="java.util.Collections"%>
<%@page import="javax.cache.CacheManager"%>
<%@page import="javax.cache.Cache"%>
<% request.setCharacterEncoding("utf-8"); %>
<%
Cache cache=null;
try {
    cache = CacheManager.getInstance().getCacheFactory().createCache(Collections.emptyMap());
} catch (CacheException e) {
   e.printStackTrace();
   
}
ArrayList<Articles> siteview = null;
if(cache.containsKey("new"))
{
	siteview = (ArrayList<Articles>) cache.get("new");
}
ArrayList<Articles> recent = null;
if(cache.containsKey("recent"))
{
	recent = (ArrayList<Articles>) cache.get("recent");
}
SimpleDateFormat dt = new SimpleDateFormat("MM-dd-yyyy"); 

ResourceBundle resource = ResourceBundle.getBundle("language",
		new Locale("en"));
%>

<jsp:include page="/layout/header.jsp">
	<jsp:param name="title" value='<%=resource.getString("title") %>'/>
	<jsp:param name="description" value='<%=resource.getString("description") %>'/>
	<jsp:param name="keywords" value='<%=resource.getString("keyword") %>'/>
</jsp:include>

	<div class="bd">
		<div class="bdl">
			<%@ include file='/adv/250x250.jsp'%>
			<h2><%=resource.getString("recent_article_view") %></h2>
			<ul>
				<%
				if(siteview!=null&&siteview.size()>0)
				{
				for(int i=0;i<siteview.size();i++)
				{
				%>
					<li><a href="/article/<%=siteview.get(i).getAlias()%>"><%=siteview.get(i).getTitle().getValue() %></a></li>
				<%
				}
				}
				%>
			</ul>
		</div>
		<div class="bdr">
			<h2><%=resource.getString("recent_article") %></h2>
			<hr size="1"/>
			
			<%
			if(recent!=null&&recent.size()>0)
			{
				for(int i=0;i<recent.size();i++)
				{
			%>
				<h3><a href="/article/<%=recent.get(i).getAlias()%>"><%=recent.get(i).getTitle().getValue() %></a></h3>
				<p class="at"><%=resource.getString("author") %>: <span><%=recent.get(i).getAuthor() %></span>  | 
				<%=resource.getString("date") %>: <span><%=dt.format(new Date(recent.get(i).getDate()))  %></span></p>
				<p><%=Utils.description(recent.get(i).getContent().getValue()) %></p>
			<%
				}
			}
			%>
			
		</div>
	</div>

<%@ include file='/layout/footer.jsp'%>			